package com.atguigu.day20.single02;

import org.junit.Test;

/*
设计模式:设计模式(Design Pattern)是一套被反复使用、多数人知晓的、经过分类编目的、代码设计经验的总结。
单例模式:保证程序执行时只会产生一个实例(对象)
    饿汉式: 无论是否需要对象 都先把对象创建出来
    懒汉式: 需要对象才进行创建



 */
public class HungryTest {

    @Test
    public void test03(){
        Hungry2 h1 = Hungry2.INSTANCE;
        Hungry2 h2 = Hungry2.INSTANCE;

        System.out.println(h1 == h2);
    }

    @Test
    public void test02() {
        Runtime r1 = Runtime.getRuntime();
        Runtime r2 = Runtime.getRuntime();
        System.out.println(r1 == r2);
    }

    @Test
    public void test01() {
/*
        Hungry h1 = new Hungry();
        Hungry h2 = new Hungry();
        System.out.println(h1 == h2);*/

        Hungry h1 = Hungry.INSTANCE;
        Hungry h2 = Hungry.INSTANCE;
        System.out.println(h1 == h2);
    }
}
